package com.inventory.Service.Impl;

import com.alibaba.fastjson2.util.DateUtils;
import com.common.entity.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.inventory.Mapper.InventoryMapper;
import com.inventory.Pojo.Inventory;
import com.inventory.Pojo.Outgoods;
import com.inventory.Service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class InventoryServiceImpl implements InventoryService {
    @Autowired
    private InventoryMapper inventoryMapper;

    @Override
    public void AddInventory(Inventory inventory) {
        Date date=new Date();
        //初次添加设置进库时间
        inventory.setInTime(DateUtils.toString(date));
        //出库数量为0
        inventory.setOutNum(0);
        //上月出库数量为0
        inventory.setLastmonthNum(0);

        inventoryMapper.AddInventory(inventory);
    }

    @Override
    public PageInfo<Inventory> SearchInventory(Integer pageNum, Integer pageSize, String goodsId, String storehouseId) {
        PageHelper.startPage(pageNum,pageSize);
        List<Inventory> inventoryList=inventoryMapper.SearchInventory(goodsId,storehouseId);
        PageInfo<Inventory> pageInfo=new PageInfo<>(inventoryList);
        return pageInfo;
    }

    @Override
    public Inventory getByid(Integer inventoryId) {
        return inventoryMapper.getByid(inventoryId);
    }

    @Override
    public void AddInNum(Integer newNum, Integer inventoryId,String intime,Integer lastmonthNum ) {

        inventoryMapper.AddInNum(newNum,inventoryId,intime,lastmonthNum);
    }

    @Override
    public void OutNum(Integer newNum, Integer outSum, String outtime, Integer inventoryId) {

        inventoryMapper.OutNum(newNum,outSum,outtime,inventoryId);
    }

    @Override
    public Inventory getBygoodsId(Integer goodsId) {
        return inventoryMapper.getBygoodsId(goodsId);
    }

    @Override
    public void Del(Integer id) {
        inventoryMapper.Del(id);
    }

    @Override
    public void updateInventory(Inventory inventory) {
        inventoryMapper.updateInventory(inventory);
    }

    @Override
    public void outgoods(Outgoods outgoods) {
        Date date=new Date();
        outgoods.setOutgoodsTime(DateUtils.toString(date));
        inventoryMapper.outgoods(outgoods);
    }

    @Override
    public PageInfo<Outgoods> searchoutgoods(Integer pageNum, Integer pageSize, String goodsId) {
        PageHelper.startPage(pageNum,pageSize);
        List<Outgoods> outgoodsList=inventoryMapper.searchoutgoods(goodsId);
        PageInfo<Outgoods> pageInfo=new PageInfo<>(outgoodsList);
        return pageInfo;
    }

    @Override
    public List<Inventory> get() {
        return inventoryMapper.get();
    }

    @Override
    public List<Inventory> get1() {
        return inventoryMapper.get1();
    }

    @Override
    public List<Inventory> get2() {
        return inventoryMapper.get2();
    }

    @Override
    public List<Inventory> get3() {
        return inventoryMapper.get3();
    }

    @Override
    public List<Inventory> get4() {
        return inventoryMapper.get4();
    }

    @Override
    public void addNew(Inventory inventory1) {
         inventoryMapper.addNew(inventory1);
    }
    @Override
    public List<Inventory>  yuce5() {
        return inventoryMapper.yuce5();
    }


    @Override
    public List<Inventory> yuce4() {
        return inventoryMapper.yuce4();
    }
    @Override
    public List<Inventory> yuce3() {
        return inventoryMapper.yuce3();
    }
    @Override
    public List<Inventory> yuce2() {
        return inventoryMapper.yuce2();
    }
    @Override
    public List<Inventory> yuce1() {
        return inventoryMapper.yuce1();
    }
    @Override
    public List<Inventory> yuce() {
        return inventoryMapper.yuce();
    }

    @Override
    public List<Inventory> xiaoliang() {
        return inventoryMapper.xiaoliang();
    }
    @Override
    public List<Inventory> xiaoliang1() {
        return inventoryMapper.xiaoliang1();
    }
    @Override
    public List<Inventory> xiaoliang2() {
        return inventoryMapper.xiaoliang2();
    }
    @Override
    public List<Inventory> xiaoliang3() {
        return inventoryMapper.xiaoliang3();
    }
    @Override
    public List<Inventory> xiaoliang4() {
        return inventoryMapper.xiaoliang4();
    }

    @Override
    public List<Inventory> xiaoliang5() {
        return inventoryMapper.xiaoliang5();
    }


}
